





{% extends "todo/base.html" %}

{% block content %}
    <div class="row justify-content-center mt-5">
        <div class="col-md-5">
            <h2>New Todo</h2>
        </div>
    </div>
    <div class="row justify-content-center mt-5">
        <div class="col-md-5">
            {% if error %}
                <div class="alert alert-danger" role="alert">
                    {{ error }}
                </div>
            {% endif %}
            <form method="POST">
                {% csrf_token %}
                <div class="form-group">
                    <label for="title">Title</label>
                    <input type="text" name="title" class="form-control" id="title" value="{{ todo.title }}" required>
                </div>
                <div class="form-group">
                    <label for="memo">Memo</label>
                    <textarea name="memo" rows="5" class="form-control" id="memo" >{{ todo.memo }}</textarea>
                </div>
                <div class="form-group form-check">
                    <input type="checkbox" name="important" class="form-check-input" id="important" {% if todo.important %}checked{% endif %}>
                    <label class="form-check-label" for="important">Important</label>
                </div>
                <button type="submit" class="btn btn-primary">Save</button>
                <button type="button" class="btn btn-success" onclick="$('#complete').click()">Complete</button>
                <button type="button" class="btn btn-danger" onclick="$('#delete').click()">Delete</button>
            </form>
        </div>
    </div>
    {% if todo.datecompleted is None %}
        <form style='display: none;' method="POST" action="{% url 'completetodo' todo.id %}">
            {% csrf_token %}
            <button id="complete" type="submit">Complete</button>
        </form>
    {% endif %}
    <form style='display: none;' method="POST" action="{% url 'deletetodo' todo.id %}">
        {% csrf_token %}
        <button id="delete" type="submit">Delete</button>
    </form>
{% endblock %}